package com.zj.small.service.impl;

import com.zj.small.mapper.InformationMapper;
import com.zj.small.pojo.Information;
import com.zj.small.service.InformationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class InformationServiceImpl implements InformationService {
    @Autowired
    private InformationMapper informationMapper;
    @Override
    public void addInformation(Information information) {
        information.setUser_id(1);
        StringBuilder chattxt = new StringBuilder();
        StringBuilder usertxt = new StringBuilder();
        for (int i=0;i<information.getChat_text().size();i++){
            chattxt.append(information.getChat_text().get(i)).append("~");
            usertxt.append(information.getUser_text().get(i)).append("~");
        }
        System.out.println("开始写入数据库");
        informationMapper.addInformation(information.getUser_id(), information.getData_id(),chattxt.toString(),usertxt.toString());
    }
}
